Don't count time spent in Python towards the player #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're seeing a lot of time spent in Python (inefficient IO?) rather than in the player in our profiles. When I add a debug print in the python time measuring code to also count Python processor self time, I get measurements like the following:
where "Turn time" is the value we measure from
clock()in our C++ code, the first value of "times" is what the Python code currently measures, and the second value of "times" is the difference intime.process_time()for the same block of code that Python measures (lines sometimes appear in the wrong order due to buffering). It's clear that most time is spent in Python, and that the first value minus the second is a much better approximation of the time used by the bot than the current one. I get similar values outside of docker, there typically with less time spent in Python I think (but it might also just have been different maps).This will hopefully address timeouts due to large numbers of units in upcoming tournaments. Optimizing the Python code (I'm sort of suspecting the line-buffered IO??) is left as future work. :)